Ext.define('DragonApp.view.menu.MenuTree', {
    extend: 'Ext.tree.Panel',
    title: '系统菜单',
    xtype: 'menutree',

    lines: true,
    loadMask: true,
    useArrows: true,
    autoScroll: true,
    rootVisible: true,
    collapsible: true,
    singleExpand: false,

    requires: [
        'DragonApp.store.MenuTree',
        'DragonApp.view.menu.MenuTreeController'
    ],

    store: {
        type: 'menuTreeStore'
    },

    controller: 'treemenu',

    listeners: {
        itemclick: 'treeNodeSelect',
        beforerender: function(me) {

            var rolename = sessionStorage.getItem("DragonApp_role_name");

            var systemStore = Ext.create('DragonApp.store.MenuTreeSystem', {});
            var queryStore = Ext.create('DragonApp.store.MenuTreeQuery', {});

            if ('管理用户' == rolename) {

                var tree = me;
                tree.reconfigure(systemStore);

            } else if ('查询用户' == rolename) {

                var tree = me;
                tree.reconfigure(queryStore);
            }
        }
    }
});